﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Kiss.Web.OrderService;

namespace Kiss.Web
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void getButton_Click(object sender, EventArgs e)
        {
            OrderServiceClient service = new OrderServiceClient();
            Customer[] customers = service.GetCustomersByCity(cityTextBox.Text);
            gridView.DataSource = customers;
            gridView.DataBind();
        }

        protected void updateButton_Click(object sender, EventArgs e)
        {
            OrderServiceClient service = new OrderServiceClient();
            Customer customer = service.GetCustomersByCity(cityTextBox.Text)[0];
            if(!customer.City.EndsWith("X"))
                customer.City = customer.City + "X";
            else
                customer.City = customer.City.Remove(customer.City.Length - 1);
            service.UpdateCustomer(customer);
        }
    }
}
